<script setup lang="ts">
import {inject} from "vue"
// inject注入祖先提供的数据
// 参数为祖先提供数据的key
let car = inject('token')
console.log(car);
const update = ()=>{
  car.value = '自行车'
}
</script>

<template>
<div class="child1">
  <h1>孙子组件</h1>
  {{car}}
  <el-button @click="update">更新数据</el-button>
</div>
</template>

<style scoped>
.child1 {
  width: 300px;
  height: 300px;
  background: #cccccc;
}
</style>